<template>
	<view class="navTabBox">
		<scroll-view scroll-x :class="bg+' nav'" scroll-with-animation :scroll-left="scrollLeft">
			<view class="flex text-center">
				<view class="cu-item flex-sub" :class="index==TabCur?text+' cur':''" v-for="(item,index) in tabTitle" :key="index" @tap="longClick" :data-id="index">
					{{item.name}}
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: 'navLongTab',
		props: {
			tabTitle: {
				type: Array,
				default: []
			},
			bg:{
				type:String,
				default:'bg-white'
			},
			text:{
				type:String,
				default:'text-green'
			}
		},
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0
			};
		},
		methods: {
			// 导航栏点击
			longClick(e){
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				this.$emit('changeTab', this.TabCur);//设置swiper的第几页
			}
		}
	}
</script>

<style lang="scss">
</style>
